package com.annhoa.infrastructure.common;

import java.io.Serializable;

import org.springframework.data.domain.PageRequest;

/**
 * 分页对象. 包含当前页数据及分页信息如总记录数.
 * @param
 */
public  class BasePage implements Serializable {
	
	private static final long serialVersionUID = 2068355871407596026L;
	/**
	 * Creates a new {@link PageRequest} with sort parameters applied.
	 *
	 * @param page zero-based page index.
	 * @param size the size of the page to be returned.
	 * @param sort must not be {@literal null}.
	 * @since 2.0
	 */
	private PageRequest pr;
	
	private PageData pd = new PageData();
	
	private String sql;

	public BasePage(){
	}
	
	public BasePage(PageRequest pr, PageData pd, String sql) {
		this.pr = pr;
		this.pd = pd;
		this.sql = sql;
	}

	public PageRequest getPr() {
		if (pr==null) {
			return PageRequest.of(1, 5);
		}
		return pr;
	}

	public void setPr(PageRequest pr) {
		
		this.pr = pr;
	}

	public PageData getPd() {
		return pd;
	}

	public void setPd(PageData pd) {
		this.pd = pd;
	}

	public String getSql() {
		return sql;
	}

	public void setSql(String sql) {
		this.sql = sql;
	}

	@Override
	public String toString() {
		return "BasePage [pr=" + pr + ", pd=" + pd + ", sql=" + sql + "]";
	}
	
	
}